import socket
import time

while True:
    # 1.创建socket
    tcp_socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
    # 2. 链接服务器
    server_addr = ("127.0.0.1", 14121)
    tcp_socket.connect(server_addr)
    # 3. 发送数据
    tcp_socket.send("data".encode("gbk"))
    receive=tcp_socket.recv(1024)
    print(str(receive.decode('gbk')))
    time.sleep(0.01)
# 4. 关闭套接字
tcp_socket.close()